<?php
use \Roboframe\ActiveRecord\Model;
class UserRole extends Model {
  static $belongs_to = array(
    array('user')
   ,array('role') 
  );
  
  static $validates_presence_of = array(
    array('user_id')
   ,array('role_id')
  );
  
  public static function delete_all_by_role_id($role_id) {
    $urs = static::find('all', array('conditions' => array('role_id = ?', $role_id)));
    foreach($urs as $ur)  {
      $ur->delete();
    }
  }
}